package org.tsp.android.MapExample;

import java.util.Iterator;
import java.util.List;

import org.data.ListMarkersTresor;
import org.data.MarkerTresor;
import org.tsp.android.MapExample.R;
import org.utils.setting.Setting;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class ResolveViewActivity extends Activity {
		
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.resolve_view);
        
        TextView textView = (TextView) findViewById(R.id.textResolve);
        String textIndice ="" + System.getProperty("line.separator");
        
        List<MarkerTresor> laListeDesTresorsTrouver = ListMarkersTresor.getInstance().getListMarkerTresorsActif();
        
        Iterator<MarkerTresor> i = laListeDesTresorsTrouver.iterator();
        while(i.hasNext()){
        	MarkerTresor currentMarkerTresor = (MarkerTresor) i.next();        	
        	textIndice += currentMarkerTresor.getIndice() + System.getProperty("line.separator");
					
        }
        
        textIndice += (String) getString(R.string.view_resolve_CodeSecret)+ " " + System.getProperty("line.separator") + Setting.getInstance().getPassword() + System.getProperty("line.separator");
        
        if(laListeDesTresorsTrouver.size() != 0){
        	if(laListeDesTresorsTrouver.size() == 1){
        		textView.setText((String) getString(R.string.view_resolve_Indice) + textIndice);
        	}else{
        		textView.setText((String) getString(R.string.view_resolve_Indices) + textIndice);
        	}
        }else{
    		textView.setText((String) getString(R.string.view_resolve_PasIndice) + textIndice);        	
        }
	}
	public void OnButtonValiderClick(View v){
		TextView textView = (TextView) findViewById(R.id.txtResolver);
		String message = "";
		if(String.valueOf(textView.getText()).equals(Setting.getInstance().getPassword())){
			message = (String) getString(R.string.view_resolve_Bravo);
		}else{
			message = (String) getString(R.string.view_resolve_KO);		
		}
		textView.setText(message);		
	}	
	public void OnButtonRetourClick(View v){
		 Intent intent = new Intent(ResolveViewActivity.this,MyMapActivity.class);
	     startActivity(intent);		 
	}	
}
